package com.zzptc.mzb.myapplication

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.POST

class MainActivity : AppCompatActivity() {

    interface SearcgService{
        @FormUrlEncoded
        @POST("Interface/UserLine/search")
        fun getAllsearch(@Field("pos") pos: Int):Call<SearchData>

    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        // SearchData("r",7, listOf())
        val builder = Retrofit.Builder()
            .baseUrl("http://hh1.me:5001/")
            .addConverterFactory(GsonConverterFactory.create())
            .build()
        val searchService = builder.create(SearcgService::class.java)
        var call = searchService.getAllsearch(1)
        call.enqueue(object : Callback<SearchData> {
            override fun onFailure(call: Call<SearchData>, t: Throwable) {
                TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
            }

            override fun onResponse(call: Call<SearchData>, response: Response<SearchData>) {
             tx_text.text=response.body()?.message
            }


        })
    }
    fun f1(){

    }
}
